\defmodule {LaplaceGen}

This class implements methods for generating random variates from the 
{\em Laplace\/} distribution. Its density is
\begin{htmlonly}
\eq
  f(x) = (1/(2\beta)) e^{-|x - \mu|/\beta}\mbox{ for }-\infty < x < \infty
\endeq
\end{htmlonly}
\begin{latexonly}
(see \cite[page 165]{tJOH95b})
\eq
    f(x) = \frac{1}{2\beta}e^{-|x-\mu|/\beta}
    \qquad \mbox {for } -\infty < x < \infty,      \eqlabel{eq:flaplace}     
\endeq
\end{latexonly}
where $\beta > 0$.

The (non-static) \texttt{nextDouble} method simply calls \texttt{inverseF} on the
distribution. 

\bigskip\hrule


\begin{code}
\begin{hide}
/*
 * Class:        LaplaceGen
 * Description:  generator of random variates from the Laplace distribution
 * Environment:  Java
 * Software:     SSJ 
 * Copyright (C) 2001  Pierre L'Ecuyer and Universite de Montreal
 * Organization: DIRO, Universite de Montreal
 * @author       
 * @since

 * SSJ is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License (GPL) as published by the
 * Free Software Foundation, either version 3 of the License, or
 * any later version.

 * SSJ is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * A copy of the GNU General Public License is available at
   <a href="http://www.gnu.org/licenses">GPL licence site</a>.
 */
\end{hide}
package umontreal.iro.lecuyer.randvar;\begin{hide}
import umontreal.iro.lecuyer.rng.*;
import umontreal.iro.lecuyer.probdist.*;
\end{hide}

public class LaplaceGen extends RandomVariateGen \begin{hide} {
   private double mu;
   private double beta;
\end{hide}\end{code}

\subsubsection* {Constructors}
\begin{code}

   public LaplaceGen (RandomStream s, double mu, double beta) \begin{hide} {
      super (s, new LaplaceDist(mu, beta));
      setParams (mu, beta);
   }\end{hide}
\end{code} 
\begin{tabb}  Creates a Laplace random variate generator with parameters
  $\mu$ = \texttt{mu} and $\beta$ = \texttt{beta}, using stream \texttt{s}. 
\end{tabb}
\begin{code}

   public LaplaceGen (RandomStream s) \begin{hide} {
      this (s, 0.0, 1.0);
   }\end{hide}
\end{code} 
\begin{tabb}  Creates a Laplace random variate generator with parameters
  $\mu = 0$ and $\beta = 1$, using stream \texttt{s}. 
\end{tabb}
\begin{code}
   
   public LaplaceGen (RandomStream s, LaplaceDist dist) \begin{hide} {
      super (s, dist);
      if (dist != null)
         setParams (dist.getMu(), dist.getBeta());
   } \end{hide}
\end{code}
 \begin{tabb}  Creates a new generator for the Laplace distribution \texttt{dist}
   and stream \texttt{s}. 
 \end{tabb}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
\subsubsection* {Methods}
\begin{code}

   public static double nextDouble (RandomStream s, double mu, double beta)\begin{hide} {
      return LaplaceDist.inverseF (mu, beta, s.nextDouble());
   }\end{hide}
\end{code}
\begin{tabb}
   Generates a new variate from the Laplace distribution with parameters 
   $\mu = $~\texttt{mu} and $\beta = $~\texttt{beta}, using stream \texttt{s}.
\end{tabb}
\begin{code}
   
   public double getMu()\begin{hide} {
      return mu;
   }\end{hide}
\end{code}
  \begin{tabb} Returns the parameter $\mu$.
  \end{tabb}
\begin{code}

   public double getBeta()\begin{hide} {
      return beta;
   }\end{hide}
\end{code}
  \begin{tabb} Returns the parameter $\beta$.
  \end{tabb}
\begin{hide}\begin{code}

   protected void setParams (double mu, double beta) {
     if (beta <= 0.0)
         throw new IllegalArgumentException ("beta <= 0");
      this.mu = mu;
      this.beta = beta;
   }
\end{code}
\begin{tabb}
   Sets the parameters $\mu$ and $\beta$  of this object.
\end{tabb}
\begin{code}
}
\end{code}
\end{hide}
